package com.tornado.community.mapper.custome;

import com.tornado.community.model.User;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

@Component
@Mapper
public interface MyUserMapper {

    @Insert("INSERT INTO user (name, account_id, token, gmt_create, gmt_modify, bio, avatar_url) VALUES (#{name}, #{accountId}, #{token}, #{gmtCreate}, #{gmtModify}, #{bio}, #{avatarUrl})")
    void insertUser(User user);

    @Select("SELECT * FROM user WHERE token = #{token}")
    User selectByToken(@Param("token") String token);

    @Select("SELECT * FROM user Where account_id = #{accountId}")
    User selectByAccountId(@Param("accountId") String accountId);

    @Update("UPDATE user SET name = #{name}, account_id = #{accountId}, token = #{token}, gmt_modify = #{gmtModify}, bio = #{bio}, avatar_url = #{avatarUrl} WHERE id = #{id}")
    void updateUser(User user);
}
